package data_structure.date12_22;

import jdk.internal.org.objectweb.asm.tree.MultiANewArrayInsnNode;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class Demo2 {
    public static void main(String[] args) {
        ArrayList arrayList = new ArrayList();
        arrayList.add(1);
        arrayList.add(2);
        //向上转型
        List list = arrayList;
        Collection collection = arrayList;
        Iterable iterable = arrayList;

        //Iterator:变量类型
        //it:变量名
        Iterator it = iterable.iterator();
        //遍历
        while (it.hasNext()) {
            Object next = it.next();
            System.out.println(next);
        }
        /*
        boolean b = it.hasNext();
        System.out.println(b);
        Object next=it.next();
        System.out.println(next);

        b= it.hasNext();
        System.out.println(next);

        b= it.hasNext();
        System.out.println(next);
    }*/
    }
}
